#define  _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
using namespace std;
//vector<int> singleNumber(vector<int>& nums) {
//    vector<int> v;
//    vector<int> ret;
//    for (int e : nums)
//    {
//        ++v[e];
//    }
//    int count = 0;
//    for (int e : v)
//    {
//        ++count;
//        if (e == 1)
//            ret.push_back(count);
//    }
//    return ret;
//}
vector<int> singleNumber(vector<int>& nums) {
    int max = 0;
    for (int e : nums)
    {
        if (e > max)
        {
            max = e;
        }
    }
    vector<int> v(max+1 , 0);
    vector<int> ret;
    for (int e : nums)
    {
        v[e]++;
    }
    int count = 0;
    for (int e : v)
    {
        ++count;
        if (e == 1)
            ret.push_back(count-1);
    }
    return ret;
}
class Solution {
public:
    vector<int> singleNumber(vector<int>& nums) {
        unordered_map<int, int> v;
        vector<int> ret;
        for (int e : nums)
        {
            ++v[e];
        }
        for (auto [num1, num2] : v)
        {
            if (num2 == 1)
                ret.push_back(num1);
        }
        return ret;
    }
};
int main()
{
    vector<int> nums = { 1,2,3,4,5,6 };

    vector<int> v = singleNumber(nums);
    for (int &e : v)
    {
        cout << e<<" ";
    }
    return 0;
}
